package com.ruoyi.collaboration.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.collaboration.domain.JwIndustryEduCollaboration;
import com.ruoyi.collaboration.service.IJwIndustryEduCollaborationService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 产学合作项目情况Controller
 * 
 * @author ruoyi
 * @date 2024-11-13
 */
@RestController
@RequestMapping("/collaboration/collaboration")
public class JwIndustryEduCollaborationController extends BaseController
{
    @Autowired
    private IJwIndustryEduCollaborationService jwIndustryEduCollaborationService;

    /**
     * 查询产学合作项目情况列表
     */
    @PreAuthorize("@ss.hasPermi('collaboration:collaboration:list')")
    @GetMapping("/list")
    public TableDataInfo list(JwIndustryEduCollaboration jwIndustryEduCollaboration)
    {
        startPage();
        List<JwIndustryEduCollaboration> list = jwIndustryEduCollaborationService.selectJwIndustryEduCollaborationList(jwIndustryEduCollaboration);
        return getDataTable(list);
    }

    /**
     * 导出产学合作项目情况列表
     */
    @PreAuthorize("@ss.hasPermi('collaboration:collaboration:export')")
    @Log(title = "产学合作项目情况", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, JwIndustryEduCollaboration jwIndustryEduCollaboration)
    {
        List<JwIndustryEduCollaboration> list = jwIndustryEduCollaborationService.selectJwIndustryEduCollaborationList(jwIndustryEduCollaboration);
        ExcelUtil<JwIndustryEduCollaboration> util = new ExcelUtil<JwIndustryEduCollaboration>(JwIndustryEduCollaboration.class);
        util.exportExcel(response, list, "产学合作项目情况数据");
    }

    /**
     * 获取产学合作项目情况详细信息
     */
    @PreAuthorize("@ss.hasPermi('collaboration:collaboration:query')")
    @GetMapping(value = "/{iecId}")
    public AjaxResult getInfo(@PathVariable("iecId") Long iecId)
    {
        return success(jwIndustryEduCollaborationService.selectJwIndustryEduCollaborationByIecId(iecId));
    }

    /**
     * 新增产学合作项目情况
     */
    @PreAuthorize("@ss.hasPermi('collaboration:collaboration:add')")
    @Log(title = "产学合作项目情况", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody JwIndustryEduCollaboration jwIndustryEduCollaboration)
    {
        SysUser user= SecurityUtils.getLoginUser().getUser();
        jwIndustryEduCollaboration.setDeptId(104L);
        jwIndustryEduCollaboration.setUserId(user.getUserId());
        return toAjax(jwIndustryEduCollaborationService.insertJwIndustryEduCollaboration(jwIndustryEduCollaboration));
    }

    /**
     * 修改产学合作项目情况
     */
    @PreAuthorize("@ss.hasPermi('collaboration:collaboration:edit')")
    @Log(title = "产学合作项目情况", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody JwIndustryEduCollaboration jwIndustryEduCollaboration)
    {
        return toAjax(jwIndustryEduCollaborationService.updateJwIndustryEduCollaboration(jwIndustryEduCollaboration));
    }

    /**
     * 删除产学合作项目情况
     */
    @PreAuthorize("@ss.hasPermi('collaboration:collaboration:remove')")
    @Log(title = "产学合作项目情况", businessType = BusinessType.DELETE)
	@DeleteMapping("/{iecIds}")
    public AjaxResult remove(@PathVariable Long[] iecIds)
    {
        return toAjax(jwIndustryEduCollaborationService.deleteJwIndustryEduCollaborationByIecIds(iecIds));
    }
}
